package sqlbuilder;

/**
 * @Classname Test
 * @Description TODO
 * @Date 2021/8/13 16:27
 * @Created by xx
 */
public class Test {

    public static void main(String[] args) {
        String s=getSql(null,null,null);
       String s1= getSql("刘",null,null);
       String s2=getSql("刘","13" ,null);
       String s3=getSql("刘","13" ,"admin");
        String s4=getSql(null,"13" ,"admin");
        String s5=getSql("刘",null ,"admin");
      //  System.out.println(s);
       // System.out.println(s1);
        //System.out.println(s2);
        //System.out.println(s3);
       // System.out.println(s4);
        System.out.println(s5);
//        SqlBuilder sqlBuilder=new SqlBuilder();
//        sqlBuilder.select(" * ").from("org_user");
//
//        sqlBuilder.and("user_name").like("刘").and("state").eq(1).page(1,10);
//        System.out.println(sqlBuilder.getPage());
//        System.out.println(sqlBuilder.getCountSql());
    }

    public static String getSql(String name,String age,String username){
        SqlBuilder sqlBuilder=new SqlBuilder();
        sqlBuilder.select(" * ").from("org_user");
        if(name!=null){
            sqlBuilder.and("name").like(name);
        }
        if(age!=null){
            sqlBuilder.and("age").eq(age);
        }
        if(username!=null){
            sqlBuilder.or("username").like(username);
        }
        sqlBuilder.page(1,10);
      //  System.out.println(sqlBuilder.getPage());
      //  System.out.println(sqlBuilder.getCountSql());
        return sqlBuilder.toString();
    }
}
